#pragma once
#include<iostream>
#include<assert.h>
using std::cin;
using std::cout;
using std::endl;
using std::istream;
using std::ostream;


namespace Mack
{
	class string
	{
	public:
		typedef char* iterator;
        string(const string& s);
		string& operator=(const string& s);
		string(const char* str = "");
		~string();

		const char* c_str() const;
		size_t size() const;

		char& operator[](size_t pos);
		const char& operator[](size_t pos) const;

		iterator begin();
		iterator end();

		void reserve(size_t n = 0);
		void push_back(char ch);
		void append(const char* str);

		string& operator+=(char ch);
		string& operator+=(const char* ch);

		void insert(size_t pos, char ch);
		void insert(size_t pos, const char* str);
		void erase(size_t pos, size_t len);

		size_t find(char ch, size_t pos);
		size_t find(const char* sub, size_t pos);

		void swap(string& s);

		string substr(size_t pos, size_t len);

		bool operator<(const string& s) const;
		bool operator<=(const string& s) const;
		bool operator>(const string& s) const;
		bool operator>=(const string& s) const;
		bool operator==(const string& s) const;
		bool operator!=(const string& s) const;

		void clear();


	private:
		char* _str;
		size_t _capacity;
		size_t _size;
		const static size_t npos;
	};
	ostream& operator<< (ostream& os, const string& str);
	istream& operator>> (istream& is, string& str);
}